﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Storm.TextEditor.Editor.CodeCompletion
{
    /// <summary>
    /// Provides a base for all CodeCompletion data provider classes.
    /// </summary>
    public interface ICompletionDataProvider
    {
        /// <summary>
        /// Gets or sets whether the CodeCompletionWindow currently may be shown.
        /// </summary>
        bool AllowShow { get; set; }

        /// <summary>
        /// Gets whether the provider uses the AllowShow property or the OnBeforeShow method to validate environments.
        /// </summary>
        bool UseAllowShow { get; }

        /// <summary>
        /// Gets or sets the image list.
        /// </summary>
        /// <value>The image list.</value>
        ImageList ImageList { get; set; }

        /// <summary>
        /// Gets the completion data.
        /// </summary>
        /// <value>The completion data.</value>
        CompletionDataCollection CompletionData { get; }

        /// <summary>
        /// Creates the completion data.
        /// </summary>
        /// <returns></returns>
        CompletionDataCollection CreateCompletionData();

        /// <summary>
        /// Called when some code has been completed.
        /// </summary>
        /// <param name="completionCharacter">The char that completed the code.</param>
        /// <param name="show">Whether the window should be reshown when the code has been completed.</param>
        void OnCodeCompleted(char completionCharacter, out bool show);

        /// <summary>
        /// Called when the selected item of the CodeCompletionWindow has changed.
        /// </summary>
        /// <param name="selectedItem">The newly selected item.</param>
        void OnSelectedItemChanged(ICompletionData selectedItem);

        /// <summary>
        /// Called just before the code completion window should show. If cancel is set to true, the window will not show. The completion data is expected to set the caret position itself.
        /// </summary>
        /// <param name="pressedChar">The pressed character.</param>
        /// <param name="cancel">Whether the window should be shown or not.</param>
        void OnBeforeShow(char pressedChar, out bool cancel);

        /// <summary>
        /// Called when the code completion window is hidden.
        /// </summary>
        void OnWindowHidden();
    }
}
